//
//  GDNewsListCell.m
//  爱新奇－味道
//
//  Created by 热带雨林 on 17/2/18.
//  Copyright © 2017年 热带雨林. All rights reserved.
//

#import "GDNewsListCell.h"
#import "UIImageView+WebCache.h"
#import "Masonry.h"

@implementation GDNewsListCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setupUI{
    //自定义分隔线
    UIView *lineView = [[UIView alloc]init];
    lineView.backgroundColor = [UIColor grayColor];
    [self.contentView addSubview:lineView];
    [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.equalTo(self.contentView);
        make.height.mas_equalTo(1/[UIScreen mainScreen].scale);
    }];
    
    self.imageView_news.layer.cornerRadius = 5;
    self.imageView_news.layer.masksToBounds = YES;
    
    
    
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    }

-(void)setModel:(GDNewListModel *)model{
    
    _model = model;
    [self setupUI];
    self.title_news.text = model.title;
    self.source_news.text = model.source;
    self.replayCount_news.text = [NSString stringWithFormat:@"%d人跟帖",model.recSource.intValue];
    //填充单张图片
    NSURL *url = [NSURL URLWithString:model.imgsrc];
    [self.imageView_news sd_setImageWithURL:url];
    
    
    //填充多张
    if(model.imgextra){
        [self.imageViews_news enumerateObjectsUsingBlock:^(UIImageView *_Nonnull ima, NSUInteger idx, BOOL * _Nonnull stop) {
           
            NSDictionary *dic = model.imgextra[idx];
            NSString *imgArr = dic[@"imgsrc"];
            NSURL *url = [NSURL URLWithString:imgArr];
            [ima sd_setImageWithURL:url];
            
        }];
    }
    
    
}

@end
